/* @flow */
import * as React from 'react';
import {Entity} from 'draft-js';
import {ENTITY_TYPE} from './../constants';


export function Image(props_) {
  const {src} = Entity.get(props_.entityKey).getData();

  return (
    <div><img src={src} className="img-rounded" /></div>
  );
}

export function findImageEntities(contentBlock, callback) {
  contentBlock.findEntityRanges((character) => {
    const entityKey = character.getEntity();
    return (
      entityKey != null &&
      Entity.get(entityKey).getType() === ENTITY_TYPE.IMAGE
    );
  }, callback);
}
